package net.sourceforge.peers.gui;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;

import net.sourceforge.peers.Logger;

public class CallFrameStateUas extends CallFrameState {

    public CallFrameStateUas(String id, CallFrame callFrame, Logger logger) {
        super(id, callFrame, logger);
        callPanel = new JPanel();
        callPanel.add(new JLabel("收到来电"));
        JButton hangupButton = new JButton("拒接");
        hangupButton.setActionCommand(CallFrame.BUSY_HERE_ACTION_COMMAND);
        hangupButton.addActionListener(callFrame);
        callPanel.add(hangupButton);
        JButton pickupButton = new JButton("接听");
        pickupButton.setActionCommand(CallFrame.PICKUP_ACTION_COMMAND);
        pickupButton.addActionListener(callFrame);
        callPanel.add(pickupButton);
    }

    @Override
    public void pickupClicked() {
        callFrame.setState(callFrame.SUCCESS);
        callFrame.pickup();
        callFrame.setCallPanel(callFrame.SUCCESS.callPanel);
    }

    @Override
    public void busyHereClicked() {


        callFrame.setState(callFrame.TERMINATED);
        callFrame.busyHere();
    }

    @Override
    public void remoteHangup() {


        callFrame.setState(callFrame.REMOTE_HANGUP);
        callFrame.setCallPanel(callFrame.REMOTE_HANGUP.callPanel);
    }

}
